<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="fn">切换</button>
        <p v-show="flag">贝利亚大王</p>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                flag: true,
            },
            methods: {
                fn() {
                    //让所有的methods中的this都指向vue实例
                //     console.log(this == app);
                    // app.flag = !app.flag
                    this.flag = !this.flag
                }
            }
        })
    </script>
</body>

</html>